Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): simple timers implemented via the set_timeout() call #394

Merged
merged 3 commits into from
Apr 27, 2021

Conversation

TheLostLambda
Copy link
Member

@TheLostLambda TheLostLambda commented Apr 27, 2021

This plugin:

impl ZellijPlugin for State {
    fn load(&mut self) {
        subscribe(&[EventType::Timer]);
        set_timeout(1.0);
    }

    fn update(&mut self, event: Event) {
        if let Event::Timer(secs) = event {
            dbg!(secs);
            set_timeout(secs * 2.0);
        }
    }
}

Outputs:

[default-plugins/strider/src/main.rs:18] secs = 1.000064727
[default-plugins/strider/src/main.rs:18] secs = 2.000187283
[default-plugins/strider/src/main.rs:18] secs = 4.000435719
[default-plugins/strider/src/main.rs:18] secs = 8.000938307
[default-plugins/strider/src/main.rs:18] secs = 16.001934982

@TheLostLambda TheLostLambda mentioned this pull request Apr 27, 2021
12 tasks
@TheLostLambda TheLostLambda merged commit 3e8c810 into main Apr 27, 2021
@h3nill h3nill deleted the plugin-timers branch May 4, 2021 03:52
@TheLostLambda TheLostLambda restored the plugin-timers branch May 4, 2021 22:51
@TheLostLambda TheLostLambda deleted the plugin-timers branch May 4, 2021 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant